import * as TYPES from '../../actions/actionTypes'
const initialState = {
    loading: false,
    keyword: '',
    dataList: null,
    pageNum: 0,
    hasMore: true,
    pageSize: 6,
}

export default function Checks(state = initialState, action) {
    switch (action.type) {
        case TYPES.INVERTORY_GETDATA_ING:
            return {
                ...state,
                loading: true
            };
        case TYPES.INVERTORY_GETDATA_SUCCESS:
            return {
                ...state,
                loading: false,
                dataList: action.dataList,
                pageNum: action.pageNum,
                hasMore: action.hasMore,
                keyword: action.keyword
            };
        case TYPES.INVERTORY_GETDATA_FAIL:
            return {
                ...state,
                loading: false,
            };
        case TYPES.INVENTORY_DATA_UNSHIFT:
            return {
                ...state,
                dataList: action.dataList
            }
        case TYPES.SEARCH_INPUT:
            return {
                ...state,
                loading: false,
                keyword: action.keyword,
                dataList: null,
                pageNum: 0,
                hasMore: true,
            }
        default:
            return state
    }
}